package org.mparts.client.gin;

import org.mparts.client.activity.LoadCatalogActivity;
import org.mparts.client.activity.MenuActivity;
import org.mparts.client.activity.NewsActivity;
import org.mparts.client.activity.PartitemActivity;
import org.mparts.client.mvp.AppPlaceFactory;
import org.mparts.client.mvp.MpartsActivityMapper;
import org.mparts.client.ui.AddressView;
import org.mparts.client.ui.CatalogView;
import org.mparts.client.ui.IAddressView;
import org.mparts.client.ui.ICatalogView;
import org.mparts.client.ui.ILoadCatalogView;
import org.mparts.client.ui.ILoadCatalogView.ILoadCatalogPresenter;
import org.mparts.client.ui.IMainView;
import org.mparts.client.ui.IMenuView;
import org.mparts.client.ui.IMenuView.IMenuPresenter;
import org.mparts.client.ui.INewsView;
import org.mparts.client.ui.INewsView.INewsPresenter;
import org.mparts.client.ui.LoadCatalogView;
import org.mparts.client.ui.MainView;
import org.mparts.client.ui.MenuView;
import org.mparts.client.ui.NewsView;
import org.mparts.client.ui.editor.INewsEditorView;
import org.mparts.client.ui.editor.INewsEditorView.INewsEditorPresenter;
import org.mparts.client.ui.editor.IPartitemEditorView;
import org.mparts.client.ui.editor.IPartitemEditorView.IPartitemEditorPresenter;
import org.mparts.client.ui.editor.NewsEditor;
import org.mparts.client.ui.editor.PartitemEditor;
import org.mparts.shared.MpartsRequestFactory;

import com.google.gwt.activity.shared.ActivityMapper;
import com.google.gwt.core.client.GWT;
import com.google.gwt.inject.client.AbstractGinModule;
import com.google.gwt.place.shared.PlaceController;
import com.google.inject.Provides;
import com.google.inject.Singleton;
import com.google.web.bindery.event.shared.EventBus;
import com.google.web.bindery.event.shared.SimpleEventBus;

public class MpartsGinModule extends AbstractGinModule {

	@Override
	protected void configure() {
		//bind(Images.class).in(Singleton.class);
		bind(EventBus.class).to(SimpleEventBus.class).in(Singleton.class);
		bind(PlaceController.class).to(InjectablePlaceController.class).in(
				Singleton.class);

		bind(AppPlaceFactory.class).in(Singleton.class);

		// bind the mapper
		bind(ActivityMapper.class).to(MpartsActivityMapper.class).in(
				Singleton.class);

		// bind the views
		bind(IMainView.class).to(MainView.class).in(Singleton.class);
		bind(IMenuView.class).to(MenuView.class).in(Singleton.class);
		bind(ICatalogView.class).to(CatalogView.class).in(Singleton.class);
		bind(IAddressView.class).to(AddressView.class).in(Singleton.class);
		bind(INewsView.class).to(NewsView.class).in(Singleton.class);
		bind(INewsEditorView.class).to(NewsEditor.class).in(Singleton.class);
		bind(INewsPresenter.class).to(NewsActivity.class).in(Singleton.class);
		bind(INewsEditorPresenter.class).to(NewsActivity.class).in(Singleton.class);
		bind(IPartitemEditorView.class).to(PartitemEditor.class).in(Singleton.class);
		bind(IPartitemEditorPresenter.class).to(PartitemActivity.class).in(Singleton.class);
		bind(IMenuPresenter.class).to(MenuActivity.class).in(Singleton.class);
		bind(ILoadCatalogPresenter.class).to(LoadCatalogActivity.class).in(Singleton.class);
		bind(ILoadCatalogView.class).to(LoadCatalogView.class).in(Singleton.class);
		// bind(IEditDisplay.class).to(EditContactView.class);
	}

	@Provides
	@Singleton
	MpartsRequestFactory provideRequestFactory(EventBus eventBus) {
		MpartsRequestFactory rf = GWT.create(MpartsRequestFactory.class);
		rf.initialize(eventBus);
		return rf;
	}

}
